<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>中医体制测试</title>
<meta name="keywords" content="田园牧歌/有机/有机蔬菜/高端蔬菜" />
<meta name="description" content="田园牧歌/有机/有机蔬菜/高端蔬菜" />
<link rel="stylesheet" type="text/css" href="/misc/css/reset.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/home.css"  />
<script type="text/javascript" src="/misc/vendors/jquery/jquery_1.2.6.js"></script>
<script type="text/javascript" src="/misc/vendors/o2js/o2js.js"></script>
<script type="text/javascript" src="/misc/vendors/o2js/o2js_build.js"></script>
</head>
<body>
 
<style type="text/css">

.bodytitle{
	font-size:14px;
	font-weight:bold;
	color:#000;
	margin:10px auto;
}
.bodytitle span.name{
	color:#bb0000;
}
.bodytitle span.ti{
	font-weight:normal;
	color:#666;
}
table.bodytb{
	border-collapse:collapse;
	width:600px;
}
table.bodytb thead td{
	border:1px solid #c1c1c1;
	background-color:#e2e2e2;
	color:#262626;
	font-size:12px;
	padding:5px;
	text-align:center;
}
table.bodytb thead td.td3{
color:#ffffff;
background-color:#a4a4a4;	
}
table.bodytb thead td.td4{
color:#ffffff;
background-color:#878787;	
}
table.bodytb thead td.td5{
color:#ffffff;
background-color:#535353;	
}
table.bodytb thead td.td6{
color:#ffffff;
background-color:#2f2f2f;	
}
table.bodytb thead td.td7{
color:#ffffff;
background-color:#000000;	
}


table.bodytb tbody td{
border-bottom:1px dashed #c1c1c1;
padding:5px;
color:	#333;
font-size:14px;
text-align:center;
}


table.bodytb tbody td div.button{
border:1px solid #d5d5d5;
background-color:#ffffff;
width:20px;
padding:3px;
margin:0px auto;
cursor:pointer;
color:#262626;
border-radius: 3px;
}
table.bodytb tbody td div.on{
border:1px solid #f66100;
color:#ffffff;
background-color:#f88700;
}
.timu{
display:none;
height:420px;
}


#a_xia{
background-color:#63B900;
color:#FFFFFF;
border:1px solid #64B501;
border-radius: 3px;
padding:5px 10px;
cursor:pointer;
position:absolute;
right:10px;
}

#a_submit{
background-color:#EF8200;
color:#FFFFFF;
border:1px solid #EF8201;
border-radius: 3px;
padding:5px 10px;
cursor:pointer;
}
</style>
 
<script type="text/javascript" >
var baseUrl = "<?=$themeUrl?>";
var $other = <?PHP echo json_encode($other); ?>;
var $now=0;
$().ready(function(){
	fnShow(0);
}); 
function fnbodybtn($k,$kk,$i){ 
	$('.bodybtn_'+$k+'_'+$kk).removeClass('on');
	$('#bodybtn_'+$k+'_'+$kk+'_'+$i).addClass('on');
}
function fnShow(w){
	if(w > 0){
		//判断是否填正确了
	//	alert($other[$now]);
		
	}
	
	
	if(w<=0){
		w = 0;
	}
	if( w >= ($other.length-1) ){
		w = $other.length - 1;
	}
	$now = w;
	$('.timu').hide();
	$('#timu_'+$now).show();
	if($now == 0){
		$('#a_shang').hide();
	}else{
		$('#a_shang').show();
	}
	if($now == ($other.length-1)){
		$('#a_xia').hide();
		$('#a_submit').show();
	}else{
		$('#a_xia').show();
		$('#a_submit').hide();
	}
}
function fnShang(){
	fnShow($now-1);
}
function fnXia(){
	fnShow($now+1);
}


function fnST(){
	var fen = [];
	for(var i=0; i<$other.length; i++){
		var $lib = $other[i].lib;
		var tmp_fen = 0;
		for(var k=0; k<$lib.length; k++){
			tmp_fen = tmp_fen + parseInt($('.trbtn_'+i+'_'+k).find('div.on').attr('val'));
		}
		fen.push(tmp_fen);
	}
  $('button').attr('disabled','disabled');
	$.post(
		'/body/index',
		{
			fen:JSON.encode(fen)
		},
		function(e){
  		$('button').attr('disabled','');
			var ok = errorHandler(e);
			if(ok){　 
				<?PHP
				if(isset($_GET['endfunc'])){
					echo 'parent.'.$_GET['endfunc'].'(ok);';
				}
				?>
				fnReturn();
			}
		}
	);
}

/* 返回 */
function fnReturn(){
	if(defined(parent) && defined(parent.ymPrompt)){
		parent.ymPrompt.close();
	}else{
		window.close();
	}
}
</script>
 
<div style="margin:0px auto;width:600px;">
	
	<?PHP 
	$sumit = count($other);
	foreach($other as $k=>$v){
		echo '<div class="timu" id="timu_'.$k.'">';
		echo '
			<div class="bodytitle">
				第'.($k+1).'/'.($sumit).'组 <span class="name">【'.$v['name'].'】</span> 中医体质测试 <span class="ti">（本组共'.count($v['lib']).'题）</span>
			</div>
		';
		
		echo '
		<table class="bodytb">
			<thead>
					<tr>
							<td class="td1"></td>
							<td class="td2">请根据近一年的体验和感觉，回答一下问题</td>
							<td class="td3">没有<br />根本不</td>
							<td class="td4">很少<br />有一点</td>
							<td class="td5">有时<br />有些</td>
							<td class="td6">经常<br />相当</td>
							<td class="td7">总是<br />非常</td>
						</tr>
				</thead>
				<tbody>	
		';
		
		foreach($v['lib'] as $kk=>$val){
			echo '
				<tr class=" trbtn_'.$k.'_'.$kk.' ">
						<td>'.($kk+1).'</td>
						<td style="text-align:left">'.$val['topic'].'</td>
						<td>
								<div class="button bodybtn_'.$k.'_'.$kk.'" id="bodybtn_'.$k.'_'.$kk.'_0" onclick="fnbodybtn('.$k.','.$kk.',0)" val="'.$val['fen'][0].'" >'.$val['fen'][0].'</div>
							</td>
						<td>
								<div class="button bodybtn_'.$k.'_'.$kk.'" id="bodybtn_'.$k.'_'.$kk.'_1" onclick="fnbodybtn('.$k.','.$kk.',1)"  val="'.$val['fen'][1].'">'.$val['fen'][1].'</div>
							</td>
						<td>
								<div class="button bodybtn_'.$k.'_'.$kk.' on" id="bodybtn_'.$k.'_'.$kk.'_2" onclick="fnbodybtn('.$k.','.$kk.',2)" val="'.$val['fen'][2].'" >'.$val['fen'][2].'</div>
							</td>
						<td>
								<div class="button bodybtn_'.$k.'_'.$kk.'" id="bodybtn_'.$k.'_'.$kk.'_3" onclick="fnbodybtn('.$k.','.$kk.',3)" val="'.$val['fen'][3].'" >'.$val['fen'][3].'</div>
							</td>
						<td>
								<div class="button bodybtn_'.$k.'_'.$kk.'" id="bodybtn_'.$k.'_'.$kk.'_4" onclick="fnbodybtn('.$k.','.$kk.',4)" val="'.$val['fen'][4].'" >'.$val['fen'][4].'</div>
							</td>
					</tr>		
			'; 
		}
		echo '
				</tbody>
		</table>	
		';
		echo '</div>';
	}
	?> 
	<div style="margin:10px auto;position:relative;text-align: ">
		<button id="a_submit" onclick="fnST()" style="margin-left:250px;">提 交</button>
		<a href="javascript:void(0)" onclick="fnShang()" id="a_shang" style="font-size:12px;color:#006699;position:absolute;left:10px;top:10px;">上一组测试</a>
		<button onclick="fnXia()" id="a_xia" >下一组</button>
	</div>


</div>

</body>
</html>